package app.beit.fintrack.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import app.beit.fintrack.bean.summary.SummaryTrackPidDataBean;
import app.beit.fintrack.dao.SummaryPIDDao;
import app.beit.fintrack.entity.summary.SummaryTrackPidData;
import app.beit.fintrack.service.convert.SummaryTrackPIDConvert;
import app.beit.fintrack.utils.enums.ESearchByStatus;

public class SummaryPIDService {
	
	private final Logger log = Logger.getLogger(this.getClass());

	@Autowired
	private SummaryPIDDao summaryPIDDao;
	
	public List<SummaryTrackPidDataBean> getDetailsByPID(final String hospitalCode, final String searchBy, final String value, final Date dateFromAdmidTime, 
			final Date dateToAdminTime, final int start, final int end) throws Exception {
		this.log.info("get details data from type");
		final List<SummaryTrackPidData> entities = this.summaryPIDDao.getDetailsByPID(hospitalCode, searchBy, value, dateFromAdmidTime, dateToAdminTime, start, end);
		if(entities != null && entities.size() > 0){
			return SummaryTrackPIDConvert.entityToBean(entities);
		}
		
		return null;
	}

	public BigDecimal getCountPerson(final String hospitalCode, final String type, final String code, final Date dateFromAdmidTime,
			final Date dateToAdmidTime, final ESearchByStatus status)throws Exception{
		return this.summaryPIDDao.getCountPerson(hospitalCode, type, code, dateFromAdmidTime, dateToAdmidTime, status);
	}
}
